#include "Menu.h"
#include "Sprite.h"
#include "input.h"
#include "Controller.h"
#include <stdio.h>

void Menu::Init(Sprite* a_sprite, Input* a_input)
{
	sprite = a_sprite;
	MenuInput = a_input;

	//Set the default menu state
	menuState = MAIN;

	//Set the default credit screen state
	creditState = 0;

	//Initialize the number of players
	numPlayers = 0;
	index = 1;
	for(int i=0;i<NUM_PLAYERS;++i)
		picked[i] = false;

	char* pics[NUM_PLAYERS] = 
	{
		"Player1.png",
		"Player2.png",
		"Player3.png",
		"Player4.png",
	};

	for(int i = 0; i < NUM_PLAYERS; ++i)
		playerPic[i].loadTexture(pics[i]);
	for(int i = 0; i < NUM_PLAYERS; i++)
	{
		playerChoice[i].loadTexture("Hidden_Item.png");
		playerChoice[i].setScale(0.75f);
	}

	int xDist = SCREEN_WIDTH/4;
	int yDist = SCREEN_HEIGHT/3;
	for(int i = 0; i<NUM_PLAYERS; ++i)
	{
		int x, y;
		if(i%2)
			x = xDist*3;
		else
			x = xDist;
		if(i<NUM_PLAYERS/2)
			y = yDist;
		else
			y = yDist*2;
		playerPic[i].setPos(x, y);
		playerPic[i].setScale(0.75f);
	}

	//Initialize our picture sprites
	char* ourPics[NUM_PROGRAMMER_PICS] =
	{
		"Kiko.png",
		"Kyle.png",
		"Will.png"
	};

	for(int i = 0; i < NUM_PROGRAMMER_PICS; i++)
	{
		ourPicture[i].loadTexture(ourPics[i]);
		ourPicture[i].setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
	}

	//Initialize the font background sprite info
	fontBackground.loadTexture("Square.png");

	//Initialize the buttons
	for(int i = 0; i < NUM_MENU_BUTTONS; i++)
	{
		button[i].loadTexture("button.png");
	}
	//Create the height set for each button on the main menu
	int menuButtonHeight = SCREEN_HEIGHT / 6;
	//Set the button's position
	for(int i = 0; i < NUM_MAIN_MENU_BUTTONS; i++)
	{
		button[i].setPos(SCREEN_WIDTH / 4, menuButtonHeight * (i + 2) );
		button[i].setButtonType(i);
	}
	//Set the buttons for each menu state seperately
	//Options button to return to the main menu
	button[4].setPos(SCREEN_WIDTH / 8, SCREEN_HEIGHT / 3);
	button[4].setButtonType(RETURN_BUTTON);
	//Credits button to return to the main menu
	button[5].setPos(SCREEN_WIDTH / 8, SCREEN_HEIGHT / 3);
	button[5].setButtonType(RETURN_BUTTON);
	//Credits button that will switch to the next or the previous page
	//Previous page
	button[9].setPos( SCREEN_WIDTH / 8, SCREEN_HEIGHT - (SCREEN_HEIGHT / 12) );
	button[9].setButtonType(RETURN_BUTTON);
	//Next page
	button[10].setPos( SCREEN_WIDTH - (SCREEN_WIDTH / 8), SCREEN_HEIGHT - (SCREEN_HEIGHT / 12) );
	button[10].setButtonType(RETURN_BUTTON);
	//Buttons to indicate the number of players
	//2 players
	button[6].setPos(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 2);
	button[6].setButtonType(PLAYER_BUTTON);
	//3 players
	button[7].setPos( (SCREEN_WIDTH / 4) * 2, SCREEN_HEIGHT / 2);
	button[7].setButtonType(PLAYER_BUTTON);
	//4 players
	button[8].setPos( (SCREEN_WIDTH / 4) * 3, SCREEN_HEIGHT / 2);
	button[8].setButtonType(PLAYER_BUTTON);
	//The selected button
	selectedButton.loadTexture("buttonSelected.png");
	selectedButton.setPos( SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
	selectedButton.setButtonType(RETURN_BUTTON);

	//Load the texture for the sprite object
	MenuSprite[0].loadTexture("Calendar_backdrop.png");
	MenuSprite[1].loadTexture("Menu_backdrop_1.png");
	MenuSprite[2].loadTexture("MayanBackdrop.png");

	//Set the menu banner sprite
	menuBanner.loadTexture("Maze_Title.png");
	menuBanner.setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 12);

	//Initialize the font object
	text = new Text(SCREEN_HEIGHT / 18, false, false, "Jokerman");
	text->setColor(20, 180, 0, 255);

	//sounds
#ifdef USING_SOUND
	Sound.init(NUM_MENU_SOUNDS);
	Sound.loadMusic("Assets/Sounds/Menu_Music.mp3");
	Sound.playMusic();
#endif
}

CONTROLLER_STATE Menu::Update()
{
	//Switch statement to define which state the menu is in and what will happen in those states.
	switch(menuState)
	{
	case MAIN:
		{
			//Keyboard input for the different menu states
			if(MenuInput->KeyPressed(DIK_1))
			{
				menuState = CHARACTER_NUM_ENTER;
			}
			if(MenuInput->KeyPressed(DIK_2))
			{
				menuState = OPTIONS;
			}
			if(MenuInput->KeyPressed(DIK_3))
			{
				menuState = CREDITS;
			}
			if(MenuInput->KeyPressed(DIK_4))
			{
				menuState = QUIT;
			}

			//Mouse input for the different menu states
			for(int i = 0; i < NUM_MENU_BUTTONS; i++)
			{
				//If the mouse is over the current button
				if(button[i].inButton(MenuInput->getMousePosition()))
				{
					//If so check what the type of that button is in order to switch to the approproproiate menu state
					if(MenuInput->leftClicked())
					{
						switch(button[i].getButtonType())
						{
						case PLAY_BUTTON:
							  {
								  menuState = CHARACTER_NUM_ENTER;

								  break;
							  }
						case OPTIONS_BUTTON:
							  {
								  menuState = OPTIONS;

								  break;
							  }
						case CREDITS_BUTTON:
							  {
								  menuState = CREDITS;

								  break;
							  }
						case QUIT_BUTTON:
							  {
								  menuState = QUIT;

								  break;
							  }
						}
					}
				}
			}
		}
		break;
	case CHARACTER_NUM_ENTER:
		{
			if(MenuInput->KeyPressed(DIK_2))
			{
				numPlayers = 2;
				playerOrder = new int[numPlayers + 1];
				playerOrder[0] = numPlayers;
				menuState = CHARACTER_SELECT;
			}
			if(MenuInput->KeyPressed(DIK_3))
			{
				numPlayers = 3;
				playerOrder = new int[numPlayers + 1];
				playerOrder[0] = numPlayers;
				menuState = CHARACTER_SELECT;
			}
			if(MenuInput->KeyPressed(DIK_4))
			{
				numPlayers = 4;
				playerOrder = new int[numPlayers + 1];
				playerOrder[0] = numPlayers;
				menuState = CHARACTER_SELECT;
			}
			//If the mouse is over the button
			if(button[6].inButton(MenuInput->getMousePosition()))
			{
				//Than check if the mouse is clicked
				if(MenuInput->leftClicked())
				{
					numPlayers = 2;
					playerOrder = new int[numPlayers + 1];
					playerOrder[0] = numPlayers;
					menuState = CHARACTER_SELECT;
				}
			}
			//If the mouse is over the button
			if(button[7].inButton(MenuInput->getMousePosition()))
			{
				//Than check if the mouse is clicked
				if(MenuInput->leftClicked())
				{
					numPlayers = 3;
					playerOrder = new int[numPlayers + 1];
					playerOrder[0] = numPlayers;
					menuState = CHARACTER_SELECT;
				}
			}
			//If the mouse is over the button
			if(button[8].inButton(MenuInput->getMousePosition()))
			{
				//Than check if the mouse is clicked
				if(MenuInput->leftClicked())
				{
					numPlayers = 4;
					playerOrder = new int[numPlayers + 1];
					playerOrder[0] = numPlayers;
					menuState = CHARACTER_SELECT;
				}
			}
		}
		break;
	case CHARACTER_SELECT:
		{
			//Initialize the player order array
			//Mouse input for the character selection
			for(int i = 0; i < NUM_PLAYERS; i++)
			{
				//If the mouse is over the button
				if(playerPic[i].inButton(MenuInput->getMousePosition() ) && !picked[i])
				{
					//Than check if the mouse is clicked
					if(MenuInput->leftClicked())
					{
						//Set the chosen sprites position to that sprite
						playerChoice[i].setPosOfCenter(playerPic[i].getSpriteInfo().getPosOfCenter().X, playerPic[i].getSpriteInfo().getPosOfCenter().Y);
						playerOrder[index] = i;
						picked[i] = true;
						index++;
					}
				}
			}
			if(index == numPlayers + 1)
			{
				Controller::Instance()->setPlayers(playerOrder);
				return GAME;
			}
		}
		break;
	case OPTIONS:
		{
			//Input for the options state
			if(MenuInput->KeyPressed(DIK_M))
			{
				menuState = MAIN;
			}
			//If the mouse is over the current button
			if(button[4].inButton(MenuInput->getMousePosition()))
			{
				//If so check what the type of that button is in order to switch to the approproproiate menu state
				if(MenuInput->leftClicked())
				{
					menuState = MAIN;
				}
			}
		}
		break;
	case CREDITS:
		{
			//Input for the credits state
			if(MenuInput->KeyPressed(DIK_M))
			{
				menuState = MAIN;
			}
			if(button[5].inButton(MenuInput->getMousePosition()))
			{
				//If so switch to the main menu state and set the credit state
				if(MenuInput->leftClicked())
				{
					menuState = MAIN;

					creditState = 0;
				}
			}

			if(creditState > 0)
			{
				//If the previous button is pressed
				if(button[9].inButton(MenuInput->getMousePosition()))
				{
					//Increment the credits page accordingly
					if(MenuInput->leftClicked())
					{
						creditState--;
					}
				}
			}
			if(creditState < NUM_CREDIT_PAGES - 1)
			{
				//If the next button is pressed
				if(button[10].inButton(MenuInput->getMousePosition()))
				{
					//Increment the credits page accordingly
					if(MenuInput->leftClicked())
					{
						creditState++;
					}
				}
			}
		}
		break;
	case QUIT:
		{
			PostQuitMessage(0);
		}
		break;
	};
	return MENU;
}

void Menu::Render()
{
	//Switch statement to define which state the menu is in and what will happen in those states.
	switch(menuState)
	{
	case MAIN:
		{
			//Draw sprite 0 with its texture (should be the background image)
			MenuSprite[0].setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
			sprite->Draw(MenuSprite[0]);
			sprite->Draw(menuBanner);

			for(int i = 0; i < NUM_MAIN_MENU_BUTTONS; ++i)
			{
				//If the mouse is over the current button
				if(button[i].inButton(MenuInput->getMousePosition()))
				{
					//Set the selected button sprite accordingly
					selectedButton.setPos( button[i].getSpriteInfo().getPosOfCenter().X, button[i].getSpriteInfo().getPosOfCenter().Y);
					selectedButton.setButtonType( button[i].getButtonType() );

					//Draw the selected button sprite
					sprite->Draw( selectedButton.getSpriteInfo() );
				}
				else
				{
					//Draw buttons with its texture
					sprite->Draw(button[i].getSpriteInfo());
				}
			}

			//Create a buffer for the text to use
			char* buffer[NUM_MAIN_MENU_BUTTONS] =
			{
				"GAME",
				"OPTIONS",
				"CREDITS",
				"QUIT"
			};

			//Draw the text for all the buttons
			//Set and render the button text
			for(int i = 0; i < NUM_MAIN_MENU_BUTTONS; i++)
			{
				text->setPosAndSize(button[i].getSpriteInfo().getPosOfCenter().X - button[i].getSpriteInfo().getCenter().X,		//Left side of the rect
									button[i].getSpriteInfo().getPosOfCenter().Y - button[i].getSpriteInfo().getCenter().Y,		//Top of the rect
									button[i].getSpriteInfo().getPosOfCenter().X + button[i].getSpriteInfo().getCenter().X,		//Right side of the rect
									button[i].getSpriteInfo().getPosOfCenter().Y + button[i].getSpriteInfo().getCenter().Y );	//Bottom of the rect
				//Set the button text
				text->setText(buffer[i]);
				//Render the text
				text->renderCentered();
			}

			break;
		}
	case CHARACTER_NUM_ENTER:
		{
			//Draw the number of player buttons with its texture
			sprite->Draw(MenuSprite[1]);
			MenuSprite[1].setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);

			//If the mouse is over the button
			if(button[6].inButton(MenuInput->getMousePosition()))
			{
				//Set the selected button sprite accordingly
				selectedButton.setPos( button[6].getSpriteInfo().getPosOfCenter().X, button[6].getSpriteInfo().getPosOfCenter().Y);
				selectedButton.setButtonType( button[6].getButtonType() );

				//Draw the selected button sprite
				sprite->Draw( selectedButton.getSpriteInfo() );
			}
			else
			{
				sprite->Draw(button[6].getSpriteInfo());
			}
			//If the mouse is over the button
			if(button[7].inButton(MenuInput->getMousePosition()))
			{
				//Set the selected button sprite accordingly
				selectedButton.setPos( button[7].getSpriteInfo().getPosOfCenter().X, button[7].getSpriteInfo().getPosOfCenter().Y);
				selectedButton.setButtonType( button[7].getButtonType() );

				//Draw the selected button sprite
				sprite->Draw( selectedButton.getSpriteInfo() );
			}
			else
			{
				sprite->Draw(button[7].getSpriteInfo());
			}
			//If the mouse is over the button
			if(button[8].inButton(MenuInput->getMousePosition()))
			{
				//Set the selected button sprite accordingly
				selectedButton.setPos( button[8].getSpriteInfo().getPosOfCenter().X, button[8].getSpriteInfo().getPosOfCenter().Y);
				selectedButton.setButtonType( button[8].getButtonType() );

				//Draw the selected button sprite
				sprite->Draw( selectedButton.getSpriteInfo() );
			}
			else
			{
				sprite->Draw(button[8].getSpriteInfo());
			}

			//Render the text for the top of the screen
			text->setPosition(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 12);
			text->setColor(255, 255, 255, 255);
			text->setText("Enter how many players there will be.");
			text->render();

			/*NOTE: should later be changed to be more elegant*/
			//Draw the text on the buttons
			//2 players
			text->setColor(255, 0, 0, 255);
			text->setPosAndSize(button[6].getSpriteInfo().getPosOfCenter().X - button[6].getSpriteInfo().getCenter().X,		//Left side of the rect
								button[6].getSpriteInfo().getPosOfCenter().Y - button[6].getSpriteInfo().getCenter().Y,		//Top of the rect
								button[6].getSpriteInfo().getPosOfCenter().X + button[6].getSpriteInfo().getCenter().X,		//Right side of the rect
								button[6].getSpriteInfo().getPosOfCenter().Y + button[6].getSpriteInfo().getCenter().Y );	//Bottom of the rect
			//Set the button text
			text->setText("2");
			text->renderCentered();
			//3 players
			text->setPosAndSize(button[7].getSpriteInfo().getPosOfCenter().X - button[7].getSpriteInfo().getCenter().X,		//Left side of the rect
								button[7].getSpriteInfo().getPosOfCenter().Y - button[7].getSpriteInfo().getCenter().Y,		//Top of the rect
								button[7].getSpriteInfo().getPosOfCenter().X + button[7].getSpriteInfo().getCenter().X,		//Right side of the rect
								button[7].getSpriteInfo().getPosOfCenter().Y + button[7].getSpriteInfo().getCenter().Y );	//Bottom of the rect
			//Set the button text
			text->setText("3");
			text->renderCentered();
			//4 players
			text->setPosAndSize(button[8].getSpriteInfo().getPosOfCenter().X - button[8].getSpriteInfo().getCenter().X,		//Left side of the rect
								button[8].getSpriteInfo().getPosOfCenter().Y - button[8].getSpriteInfo().getCenter().Y,		//Top of the rect
								button[8].getSpriteInfo().getPosOfCenter().X + button[8].getSpriteInfo().getCenter().X,		//Right side of the rect
								button[8].getSpriteInfo().getPosOfCenter().Y + button[8].getSpriteInfo().getCenter().Y );	//Bottom of the rect
			//Set the button text
			text->setText("4");
			text->renderCentered();
		}
		break;
	case CHARACTER_SELECT:
		{
			//Set and draw the font for the character select screen
			//Create the current player's font (for choosing their character) and put it in buffer
			sprite->Draw(MenuSprite[1]);
			MenuSprite[1].setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);

			sprintf_s(buffer, 64, "Player %i select your character", index);
			text->setPosition(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 12);
			text->setText(buffer);
			text->render();

			for(int i = 0; i < NUM_PLAYERS; ++i)
			{
				sprite->Draw(playerPic[i].getSpriteInfo() );

				if(picked[i])
				{
					sprite->Draw(playerChoice[i]);
				}
			}
		}
		break;
	case OPTIONS:
		{
			//Draw sprite 1 with its texture (should be the background image)
			MenuSprite[1].setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
			sprite->Draw(MenuSprite[1]);

			//If the mouse is over the button
			if(button[4].inButton(MenuInput->getMousePosition()))
			{
				//Set the selected button sprite accordingly
				selectedButton.setPos( button[4].getSpriteInfo().getPosOfCenter().X, button[4].getSpriteInfo().getPosOfCenter().Y);
				selectedButton.setButtonType( button[4].getButtonType() );

				//Draw the selected button sprite
				sprite->Draw( selectedButton.getSpriteInfo() );
			}
			else
			{
				sprite->Draw(button[4].getSpriteInfo());
			}

			//Draw the text on the button
			text->setPosAndSize(button[4].getSpriteInfo().getPosOfCenter().X - button[4].getSpriteInfo().getCenter().X,		//Left side of the rect
								button[4].getSpriteInfo().getPosOfCenter().Y - button[4].getSpriteInfo().getCenter().Y,		//Top of the rect
								button[4].getSpriteInfo().getPosOfCenter().X + button[4].getSpriteInfo().getCenter().X,		//Right side of the rect
								button[4].getSpriteInfo().getPosOfCenter().Y + button[4].getSpriteInfo().getCenter().Y );	//Bottom of the rect
			//Set the button text
			text->setText("MENU");

			text->renderCentered();

			break;
		}
	case CREDITS:
		{
			//Draw sprite 2 with its texture (should be the background image)
			MenuSprite[2].setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
			sprite->Draw(MenuSprite[2]);
			sprite->Draw(menuBanner);

			//Draw button 5 with its texture (which should be the credit's return to menu button)
			//If the mouse is over the button
			if(button[5].inButton(MenuInput->getMousePosition()))
			{
				//Set the selected button sprite accordingly
				selectedButton.setPos( button[5].getSpriteInfo().getPosOfCenter().X, button[5].getSpriteInfo().getPosOfCenter().Y);
				selectedButton.setButtonType( button[5].getButtonType() );

				//Draw the selected button sprite
				sprite->Draw( selectedButton.getSpriteInfo() );
			}
			else
			{
				sprite->Draw(button[5].getSpriteInfo());
			}

			//Draw and set the text on the buttons
			//Return to menu button
			text->setPosAndSize(button[5].getSpriteInfo().getPosOfCenter().X - button[5].getSpriteInfo().getCenter().X,		//Left side of the rect
								button[5].getSpriteInfo().getPosOfCenter().Y - button[5].getSpriteInfo().getCenter().Y,		//Top of the rect
								button[5].getSpriteInfo().getPosOfCenter().X + button[5].getSpriteInfo().getCenter().X,		//Right side of the rect
								button[5].getSpriteInfo().getPosOfCenter().Y + button[5].getSpriteInfo().getCenter().Y );	//Bottom of the rect
			//Set the button text
			text->setText("MENU");
			text->renderCentered();

			//Draw the font for the different pages depending on which page the credits screen is currently on
			switch(creditState)
			{
			case 0:
				{
					//Draw button 10 with its texture (which should be the credit's "Next" button)
					//If the mouse is over the button
					if(button[10].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[10].getSpriteInfo().getPosOfCenter().X, button[10].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[10].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[10].getSpriteInfo());
					}

					fontBackground.setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4);
					fontBackground.setScale(1.0, 0.25);
					sprite->Draw(fontBackground);

					//Draw Kiko's picture
					sprite->Draw(ourPicture[0]);

					//Next button
					text->setPosAndSize(button[10].getSpriteInfo().getPosOfCenter().X - button[10].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y - button[10].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[10].getSpriteInfo().getPosOfCenter().X + button[10].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y + button[10].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("NEXT");
					text->renderCentered();

					text->setColor(255, 0, 0, 255);
					text->setPosAndSize(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 6, SCREEN_WIDTH - (SCREEN_WIDTH / 4), SCREEN_HEIGHT / 3);
					text->setText("FRANCISCO OLVERA:");
					text->renderCentered();

					text->setColor(255, 255, 255, 255);
					text->setPosAndSize(SCREEN_WIDTH / 4, SCREEN_HEIGHT - (SCREEN_HEIGHT / 3), SCREEN_WIDTH - (SCREEN_WIDTH / 4), SCREEN_HEIGHT - (SCREEN_HEIGHT / 6) );
					text->setText("Lead programmer");
					text->renderCentered();

					break;
				}
				case 1:
				{
					//Draw button 9 with its texture (which should be the credit's "Previous" button)
					//If the mouse is over the button
					if(button[9].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[9].getSpriteInfo().getPosOfCenter().X, button[9].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[9].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[9].getSpriteInfo());
					}
					//Draw button 10 with its texture (which should be the credit's "Next" button)
					//If the mouse is over the button
					if(button[10].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[10].getSpriteInfo().getPosOfCenter().X, button[10].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[10].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[10].getSpriteInfo());
					}

					//Previous button
					text->setPosAndSize(button[9].getSpriteInfo().getPosOfCenter().X - button[9].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y - button[9].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[9].getSpriteInfo().getPosOfCenter().X + button[9].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y + button[9].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("PREVIOUS");
					text->renderCentered();

					//Next button
					text->setPosAndSize(button[10].getSpriteInfo().getPosOfCenter().X - button[10].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y - button[10].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[10].getSpriteInfo().getPosOfCenter().X + button[10].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y + button[10].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("NEXT");
					text->renderCentered();

					fontBackground.setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4);
					fontBackground.setScale(1.0, 0.25);
					sprite->Draw(fontBackground);

					//Draw Kyle's picture
					sprite->Draw(ourPicture[1]);

					text->setColor(255, 0, 0, 255);
					text->setPosAndSize(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 6, SCREEN_WIDTH - (SCREEN_WIDTH / 4), SCREEN_HEIGHT / 3);
					text->setText("KYLE LOWRY:");
					text->renderCentered();

					text->setColor(255, 255, 255, 255);
					text->setPosAndSize(SCREEN_WIDTH / 4, SCREEN_HEIGHT - (SCREEN_HEIGHT / 3), SCREEN_WIDTH - (SCREEN_WIDTH / 4), SCREEN_HEIGHT - (SCREEN_HEIGHT / 6) );
					text->setText("Programmer, Production manager");
					text->renderCentered();

					break;
				}
				case 2:
				{
					//Draw button 9 with its texture (which should be the credit's "Previous" button)
					//If the mouse is over the button
					if(button[9].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[9].getSpriteInfo().getPosOfCenter().X, button[9].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[9].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[9].getSpriteInfo());
					}
					//Draw button 10 with its texture (which should be the credit's "Next" button)
					//If the mouse is over the button
					if(button[10].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[10].getSpriteInfo().getPosOfCenter().X, button[10].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[10].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[10].getSpriteInfo());
					}

					//Previous button
					text->setPosAndSize(button[9].getSpriteInfo().getPosOfCenter().X - button[9].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y - button[9].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[9].getSpriteInfo().getPosOfCenter().X + button[9].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y + button[9].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("PREVIOUS");
					text->renderCentered();

					//Next button
					text->setPosAndSize(button[10].getSpriteInfo().getPosOfCenter().X - button[10].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y - button[10].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[10].getSpriteInfo().getPosOfCenter().X + button[10].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y + button[10].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("NEXT");
					text->renderCentered();

					fontBackground.setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4);
					fontBackground.setScale(1.0, 0.25);
					sprite->Draw(fontBackground);

					//Draw Will's picture
					sprite->Draw(ourPicture[2]);

					text->setColor(255, 0, 0, 255);
					text->setPosAndSize(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 6, SCREEN_WIDTH - (SCREEN_WIDTH / 4), SCREEN_HEIGHT / 3);
					text->setText("WILL ZEPEDA:");
					text->renderCentered();

					text->setColor(255, 255, 255, 255);
					text->setPosAndSize(SCREEN_WIDTH / 6, SCREEN_HEIGHT - (SCREEN_HEIGHT / 3), SCREEN_WIDTH - (SCREEN_WIDTH / 6), SCREEN_HEIGHT - (SCREEN_HEIGHT / 6) );
					text->setText("Programmer, Modeler, Artist, Musician");
					text->renderCentered();

					break;
				}
				case 3:
				{
					//Draw button 9 with its texture (which should be the credit's "Previous" button)
					//If the mouse is over the button
					if(button[9].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[9].getSpriteInfo().getPosOfCenter().X, button[9].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[9].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[9].getSpriteInfo());
					}
					//Draw button 10 with its texture (which should be the credit's "Next" button)
					//If the mouse is over the button
					if(button[10].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[10].getSpriteInfo().getPosOfCenter().X, button[10].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[10].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[10].getSpriteInfo());
					}

					//Previous button
					text->setPosAndSize(button[9].getSpriteInfo().getPosOfCenter().X - button[9].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y - button[9].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[9].getSpriteInfo().getPosOfCenter().X + button[9].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y + button[9].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("PREVIOUS");
					text->renderCentered();

					//Next button
					text->setPosAndSize(button[10].getSpriteInfo().getPosOfCenter().X - button[10].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y - button[10].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[10].getSpriteInfo().getPosOfCenter().X + button[10].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y + button[10].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("NEXT");
					text->renderCentered();

					fontBackground.setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 3);
					fontBackground.setScale(1.0, 0.25);
					sprite->Draw(fontBackground);

					text->setColor(0, 0, 255, 255);
					text->setPosAndSize(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 6, SCREEN_WIDTH - (SCREEN_WIDTH / 4), SCREEN_HEIGHT / 2);
					text->setText("SPECIAL THANKS\n"
								  "==================\n");
					text->renderCentered();

					//Set the credits font and draw it
					text->setColor(255, 255, 255, 255);
					text->setPosition(SCREEN_WIDTH / 16, SCREEN_HEIGHT / 5);
					text->setText("David Walker:\n"
								  " - Continual help and support\n"
								  "Michael Vaganov:\n"
								  " - Continual help and support\n");
					text->renderCentered();

					break;
				}
				case 4:
				{
					//Draw button 9 with its texture (which should be the credit's "Previous" button)
					//If the mouse is over the button
					if(button[9].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[9].getSpriteInfo().getPosOfCenter().X, button[9].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[9].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[9].getSpriteInfo());
					}
					//Draw button 10 with its texture (which should be the credit's "Next" button)
					//If the mouse is over the button
					if(button[10].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[10].getSpriteInfo().getPosOfCenter().X, button[10].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[10].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[10].getSpriteInfo());
					}

					//Previous button
					text->setPosAndSize(button[9].getSpriteInfo().getPosOfCenter().X - button[9].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y - button[9].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[9].getSpriteInfo().getPosOfCenter().X + button[9].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y + button[9].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("PREVIOUS");
					text->renderCentered();

					//Next button
					text->setPosAndSize(button[10].getSpriteInfo().getPosOfCenter().X - button[10].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y - button[10].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[10].getSpriteInfo().getPosOfCenter().X + button[10].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y + button[10].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("NEXT");
					text->renderCentered();

					fontBackground.setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4);
					fontBackground.setScale(1.0, 0.25);
					sprite->Draw(fontBackground);

					text->setColor(0, 0, 255, 255);
					text->setPosAndSize(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 6, SCREEN_WIDTH - (SCREEN_WIDTH / 4), SCREEN_HEIGHT / 3);
					text->setText("ART\n"
								  "======\n");
					text->renderCentered();

					//Set the credits font and draw it
					text->setColor(255, 255, 255, 255);
					text->setPosition(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 3);
					text->setText("DAVID JACKSON:\n"
								  " - 2D art for the artifacts\n"
								  "RYAN SCHROEDEL:\n"
								  " - Background image for the main menu\n"
								  " - Background image for the options menu\n"
								  " - Background image for the credits menu\n"
								  " - Background image for the end game screen\n");
					text->render();

					break;
				}
			case 5:
				{
					//Draw button 9 with its texture (which should be the credit's "Previous" button)
					//If the mouse is over the button
					if(button[9].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[9].getSpriteInfo().getPosOfCenter().X, button[9].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[9].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[9].getSpriteInfo());
					}
					//Draw button 10 with its texture (which should be the credit's "Next" button)
					//If the mouse is over the button
					if(button[10].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[10].getSpriteInfo().getPosOfCenter().X, button[10].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[10].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[10].getSpriteInfo());
					}

					//Previous button
					text->setPosAndSize(button[9].getSpriteInfo().getPosOfCenter().X - button[9].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y - button[9].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[9].getSpriteInfo().getPosOfCenter().X + button[9].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y + button[9].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("PREVIOUS");
					text->renderCentered();

					//Next button
					text->setPosAndSize(button[10].getSpriteInfo().getPosOfCenter().X - button[10].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y - button[10].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[10].getSpriteInfo().getPosOfCenter().X + button[10].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y + button[10].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("NEXT");
					text->renderCentered();

					fontBackground.setPosOfCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4);
					fontBackground.setScale(1.0, 0.25);
					sprite->Draw(fontBackground);

					text->setColor(0, 0, 255, 255);
					text->setPosAndSize(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 6, SCREEN_WIDTH - (SCREEN_WIDTH / 4), SCREEN_HEIGHT / 3);
					text->setText("ART CONTINUED\n"
								  "===============\n");
					text->renderCentered();

					//Set the credits font and draw it
					text->setColor(255, 255, 255, 255);
					text->setPosition(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 3);
					text->setText("WILL ZEPEDA:\n"
								  " - All music for the game\n"
								  " - 2D art for the artifacts\n"
								  " - 3D models for the player characters\n"
								  "KYLE LOWRY:\n"
								  " - 3D models for the board tiles\n");
					text->render();

					break;
				}
				case 6:
				{
					//Draw button 9 with its texture (which should be the credit's "Previous" button)
					//If the mouse is over the button
					if(button[9].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[9].getSpriteInfo().getPosOfCenter().X, button[9].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[9].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[9].getSpriteInfo());
					}
					//Draw button 10 with its texture (which should be the credit's "Next" button)
					//If the mouse is over the button
					if(button[10].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[10].getSpriteInfo().getPosOfCenter().X, button[10].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[10].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[10].getSpriteInfo());
					}

					//Previous button
					text->setPosAndSize(button[9].getSpriteInfo().getPosOfCenter().X - button[9].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y - button[9].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[9].getSpriteInfo().getPosOfCenter().X + button[9].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y + button[9].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("PREVIOUS");
					text->renderCentered();

					//Next button
					text->setPosAndSize(button[10].getSpriteInfo().getPosOfCenter().X - button[10].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y - button[10].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[10].getSpriteInfo().getPosOfCenter().X + button[10].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[10].getSpriteInfo().getPosOfCenter().Y + button[10].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("NEXT");
					text->renderCentered();

					fontBackground.setPosOfCenter(430, 200);
					fontBackground.setScale(1.0, 0.25);
					sprite->Draw(fontBackground);

					text->setColor(0, 0, 255, 255);
					text->setPosAndSize(SCREEN_WIDTH / 3, SCREEN_HEIGHT / 6, SCREEN_WIDTH - (SCREEN_WIDTH / 4), SCREEN_HEIGHT / 2);
					text->setText("ART STILL CONTINUED\n"
								  "====================\n");
					text->renderCentered();

					//Set the credits font and draw it
					text->setColor(255, 255, 255, 255);
					text->setPosition(SCREEN_WIDTH / 12, SCREEN_HEIGHT / 5);
					text->setText("FRANCISCO OLVERA:\n"
								  " - 3D models for the board tiles\n\n"
								  "Seamless textures for board pieces provided by spiralgraphics.biz");
					text->renderCentered();

					break;
				}
				case 7:
				{
					//Draw button 9 with its texture (which should be the credit's "Previous" button)
					//If the mouse is over the button
					if(button[9].inButton(MenuInput->getMousePosition()))
					{
						//Set the selected button sprite accordingly
						selectedButton.setPos( button[9].getSpriteInfo().getPosOfCenter().X, button[9].getSpriteInfo().getPosOfCenter().Y);
						selectedButton.setButtonType( button[9].getButtonType() );

						//Draw the selected button sprite
						sprite->Draw( selectedButton.getSpriteInfo() );
					}
					else
					{
						sprite->Draw(button[9].getSpriteInfo());
					}

					//Previous button
					text->setPosAndSize(button[9].getSpriteInfo().getPosOfCenter().X - button[9].getSpriteInfo().getCenter().X,		//Left side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y - button[9].getSpriteInfo().getCenter().Y,		//Top of the rect
										button[9].getSpriteInfo().getPosOfCenter().X + button[9].getSpriteInfo().getCenter().X,		//Right side of the rect
										button[9].getSpriteInfo().getPosOfCenter().Y + button[9].getSpriteInfo().getCenter().Y );	//Bottom of the rect
					//Set the button text
					text->setText("PREVIOUS");
					text->renderCentered();

					fontBackground.setPosOfCenter(500, SCREEN_HEIGHT / 4);
					fontBackground.setScale(1.0, 0.25);
					sprite->Draw(fontBackground);

					text->setColor(0, 0, 255, 255);
					text->setPosAndSize(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 6, SCREEN_WIDTH - (SCREEN_WIDTH / 4), SCREEN_HEIGHT / 3);
					text->setText("VOICES\n"
								  "=======\n");
					text->renderCentered();

					//Set the credits font and draw it
					text->setColor(255, 255, 255, 255);
					text->setPosition(SCREEN_WIDTH / 4, SCREEN_HEIGHT / 3);
					text->setText("INDIANAPOLIS BOB:\n\n"
								  "THE MAYAN:\n\n"
								  "THE CONQUISTADOR:\n\n"
								  "CLARA KOFF:");
					text->render();

					text->setPosition(SCREEN_WIDTH - (SCREEN_WIDTH / 4), SCREEN_HEIGHT / 3);
					text->setText("Kyle Lowry\n\n"
								  "Ryan Schroedel\n\n"
								  "Francisco Olvera\n\n"
								  "Jessica Burnett");
					text->render();

					break;
				}
			}
		}
	};
}

void Menu::Release()
{
#ifdef USING_SOUND
	//Release COM objects in the opposite order they were created in
	Sound.Release();
#endif
}